The ability to send information to different channels is a big advantage. Standard options have their inconveniences: an email can get lost in spam, and an SMS is not free of charge and does not always reach the recipient. In such conditions, the Telegram messenger can become a convenient alternative.
Telegram is a third-party service for Wialon. You can freely find guidance for the necessary settings on the internet. However, to simplify the work of our partners, in one article, we have collected the key steps that will be required to send notifications to Telegram from Wialon for public and private groups or channels, individual and bulk messages.
Preliminary requirements
Create a bot following the instructions. Hereinafter we will assume that the Telegram app is installed on your computer or phone. You can configure it in both versions, but we recommend doing it on a computer as it is easier since you will have to copy the information to the notification settings in Wialon.
Categories of notifications
Notifications can be roughly divided into two categories:
- individual — notifications for one dedicated user (for example, a client with one personal car);
- bulk — sending messages for several users at once (for example, one group, team, department, or company).
There is only one setting for Telegram notifications in Wialon — you need to set the Bot token and Channel ID:
Usually questions arise with the Channel ID. The way you fill in this field determines whether the notifications will be individual or bulk.
Individual notifications
On a computer or on the phone with Telegram installed, open this link: https://telegram.me/userinfobot
Send a command to start. In response, you get your own ID:
Then, use this own ID in the notification settings:
When such a notification is triggered, the message will be sent to the chatbot and only you will see it:
What is even more remarkable about this method is the ability to use one token for different user IDs. Thus, we use one bot for many individual notifications but each client receives only their own notification.
To find out the ID of another user, simply forward this user's message to them (for example, if you already have a chat with them, you may forward this message from there):
Bulk notifications
Public channel
Setting up the bulk sending to several users at once seems easier. It is enough to create a public Telegram channel, add a bot there, and allow it to manage notifications.
Put the channel ID in the Channel ID field for configuring notifications in Wialon:
Take only the “pach_test” part (without the symbols “t.me/”), put the “@” prefix, and add it to the notification in Wialon like this:
Then, add all the relevant contacts to this channel (all of them will receive notifications on a centralized basis). Wait for the triggered processing with the result similar to the one below:
Private channel
First, create a public channel and add a bot there with the administrator role. Send a request on behalf of the bot to this channel by pasting the following link into the address bar of the browser and pressing Enter:
https://api.telegram.org/bot<YourBOTToken>/sendMessage?chat_id=@yourchannelname&text=ping
Then replace the existing token with the token of your bot:
Enter your Channel ID:
Paste the following link into the address bar of the browser and press Enter:
https://api.telegram.org/bot775ххххххх:AAH5Kp_cххххххххххххххххх/sendMessage?chat_id=@gurtamstudy&text=ping
In response you will get:
{"ok":true,"result":{"message_id":17,"chat":{"id":-1001xxxxxxxxx,"title":"Study","username":"gurtamstudy","type":"channel"},"date":1593066856,"text":"ping"}}
Delete the message and make the channel private. Use the value "id": -1001xxxxxxxxx instead of @yourchannelname in the notification settings.
Private group
Sending notifications to a group can be useful as it gives an opportunity to its members to discuss the messages straight away. The setup process is similar to the settings for notifications to a private channel.
Create a public group and add a bot there (with or without administrator rights). Send a request on behalf of the bot to this group by pasting the following link into the address bar of the browser and pressing Enter:
https://api.telegram.org/bot<YourBOTToken>/sendMessage?chat_id=@yourgroupname&text=ping
Replace the token with the token of your bot:
Enter the ID of your group:
Paste the following link into the address bar of the browser and press Enter:
https://api.telegram.org/bot775ххххххх:AAH5Kp_cххххххххххххххххх/sendMessage?chat_id=@gurtam_study&text=ping
In response you will get:
{"ok":true,"result":{"message_id":2,"from":{"id":775ххххххх,"is_bot":true,"first_name":"pach_test","username":"pach_bot"},"chat":{"id":-1001xxxxxxxxx,"title":"Study group","username":"gurtam_study","type":"supergroup"},"date":1593070025,"text":"ping"}}
Delete the message and make the group private. Use the value "id": -1001xxxxxxxxx instead of @yourgroupname in the notification settings.